
# Keys that type a character
keyboard_character = r"`1234567890-=qwertyuiop[]\asdfghjkl;'zxcvbnm,./*+"

# Keys that don't type a character
event_KEYBOARDLIST = [
# reserve for game system
#"escape",
#"f1",
#"f2",
#"f3",
#"f4",
#"f5",
#"f6",
#"f7",
#"f8",
#"f9",
#"f10",
#"f11",
#"f12",
"scroll_lock",
"backspace",
"insert",
"home",
"page_up",
"num_lock",
"tab",
"delete",
"end",
"page_down",
"caps_lock",
"enter",
"arrow_left",
"arrow_up",
"arrow_down",
"arrow_right",
#"shift",
"lshift",
"rshift",
#"control",
#"alt",
"lcontrol",
"lalt",
"space",
"ralt",
"rcontrol",
]

event_KEYBOARDLIST.extend(list(keyboard_character))


# for controller configure
from direct.showbase import DirectObject
from EventDefine import event_ALLCONTROLLEREVENT

class KeyboardListener(DirectObject.DirectObject):
    def __init__(self):
        self.CreateAllKeyboardEvent()

    def CreateAllKeyboardEvent(self):
        for eventName in event_KEYBOARDLIST:
            self.accept(eventName,self.eventHandle,[eventName])

    def eventHandle(self, eventName):
        messenger.send(event_ALLCONTROLLEREVENT, [eventName])
